<?php Schema::init(); ?>
<script type="text/javascript">
function validateForm() {
	if (!parseInt($('#doc_schema_id').val())) {
		alert('Please select schema');
		return false;
	}

	return true;
}
</script>
<div class="schema_wrapper">
	<?php if ($error > -1) { ?>
		<div class="schema_message">
		<?php if (!$error) {
			echo __('Document inserted sucsesfuly');
		} else {
			echo __('Error inserting document');
		} ?>
		</div>
	<?php } ?>

	<div class="schema_header">
		<?php echo __('Inserting new document'); ?>
	</div>
	<form action="<?php echo CURRENT_URL; ?>" method="post" onsubmit="return validateForm()">
		<div class="schema_tabs">
			<ul class="nav nav-pills">
				<li id="schema_tab_0" class="active">
					<a href="#0" onclick="Core.Schema.openTab(0)"><?php echo __('General'); ?></a>
				</li>
			</ul>
		</div>
		<div class="schema_blocks">
			<div class="schema_block" id="schema_block_0">
				<table border="0" width="100%" cellspacing="10" cellpadding="0">
					<colgroup>
						<col class="schema_column_headers" />
						<col class="schema_column_fields" />
					</colgroup>
					<tr>
						<td class="schema_cell_header">Document name</td>
						<td class="schema_cell_field"><input type="text" id="doc_name" name="doc_name" class="schema_textfield" /></td>
					</tr>
					<tr>
						<td class="schema_cell_header">Alias</td>
						<td class="schema_cell_field"><input type="text" id="doc_alias" name="doc_alias" class="schema_textfield" /></td>
					</tr>
					<tr>
						<td class="schema_cell_header">Status</td>
						<td class="schema_cell_field">
							<select id="doc_status_id" name="doc_status_id" class="schema_select">
								<option value="1">Opened</option>
								<option value="2">Closed</option>
							</select>
						</td>
					</tr>
					<tr>
						<td class="schema_cell_header">Schema</td>
						<td class="schema_cell_field">
							<select id="doc_schema_id" name="doc_schema_id" class="schema_select">
								<option value="0">-- Select schema --</option>
								<?php Schema::drawSelect($schema_list); ?>
							</select>
						</td>
					</tr>
					<tr>
						<td class="schema_cell_header">Parent category</td>
						<td class="schema_cell_field">
							<select id="doc_cat_id" name="doc_cat_id" class="schema_select">
								<?php Category::drawTreeSelect(1, $cat_id); ?>
							</select>
						</td>
					</tr>
				</table>
			</div>
		</div>
		<div class="schema_buttons"><input type="submit" value="Insert" class="btn btn-primary" /></div>
	</form>
</div>